/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.core.runtime.event;

import com.farmcode.api.runtime.BaseEvent;
import com.farmcode.api.runtime.FARMCodeContext;
import com.farmcode.api.runtime.Response;
import java.io.File;
import java.io.FileInputStream;

/**
 *
 * @author oiprado
 */
public class DownLoadEvent extends BaseEvent<Object> {
        
    @Override
    public Response<Object> excecute(FARMCodeContext context) {
        try {
            String output = (String) context.get("output");
            File file = new File("");//oscom.global.util.ZipUtil.zipDirectory(output, "C:\\temp\\"));
            byte[] b = new byte[(int) file.length()];
            FileInputStream fileInputStream = new FileInputStream(file);
            fileInputStream.read(b);
            response.setResult(b);
        } catch (Exception ex) {
          response.addMessage(ex);
        }
        return response;
    }
}
